package com.lemon.ai.socket.packets.spiritgame.xls2Object;

import java.io.IOException;
import java.util.Arrays;

import lincen.javase.util.excel.LemonSheet;
import lincen.javase.util.excel.LemonWorkBook;

public class xlsReader {

	/**
	 * 生成内存配置类
	 * @param sourceExcelFile	源文件地址
	 * @param sheetIndex		sheet索引
	 * @param className			类名
	 * @return
	 * @throws IOException
	 */
	public Constent getConstent(String sourceExcelFile, int sheetIndex, String className) throws IOException {
		LemonWorkBook lb = new LemonWorkBook(sourceExcelFile);
		LemonSheet s = lb.getSheet(sheetIndex);
		return get(s, className);
	}
	
	/**
	 * 获取表类容
	 * @param s
	 * @param className 
	 * @return
	 */
	private Constent get(LemonSheet s, String className) {
		String[][] c = s.autoGet();
		String[] explains = c[0];
		String[] marks = c[1];
		String[] types = c[2];
		String[] filedNames = c[3];
		
//		System.out.println(Arrays.toString(explains));
		
		int d = 4;
		String [] [] constent = new String[c.length - d][c[0].length];
		
		for (int i = d; i < c.length; i++) {
			for (int j = 0; j < c[0].length; j++) {
				constent[i - d][j] = c[i][j];
			}
		}
		return new Constent(explains, marks, constent, types, filedNames, className);
	}
}
